#include <REGX52.H>
#include "lcd12864.c"
/**
 * 写数据实现黑白方格交替显示画面
 * 1x1
 * 2x2
 * 4x4
 * 8x8
 * 16x16
 * 32x32
 */

/**
 * 0x55
 * 0xAA
 */
void display_1x1()
{

    unsigned char page;
    unsigned char col;

    for (page = 0; page < 8; page++)
    {
        for (col = 0; col < 128; col += 2)
        {
            lcd_display_one_byte_in_page(page, col, 0x55);
            lcd_display_one_byte_in_page(page, col + 1, 0xAA);
        }
    }
}

void display_2x2()
{

    unsigned char page;
    unsigned char col;

    for (page = 0; page < 8; page++)
    {
        for (col = 0; col < 128; col += 4)
        {
            lcd_display_one_byte_in_page(page, col, 0xCC);
            lcd_display_one_byte_in_page(page, col + 1, 0xCC);
            lcd_display_one_byte_in_page(page, col + 2, 0x33);
            lcd_display_one_byte_in_page(page, col + 3, 0x33);
        }
    }
}

void display_4x4()
{

    unsigned char page;
    unsigned char col;

    for (page = 0; page < 8; page++)
    {
        for (col = 0; col < 128; col += 8)
        {
            lcd_display_same_bytes_in_page(page, col, 0xF0, 4);
            lcd_display_same_bytes_in_page(page, col + 4, 0x0F, 4);
        }
    }
}

void display_8x8()
{

    unsigned char page;
    unsigned char col;
    unsigned char dat = 0xFF;

    for (page = 0; page < 8; page++)
    {
        for (col = 0; col < 128; col += 16)
        {
            lcd_display_same_bytes_in_page(page, col, dat, 8);
            lcd_display_same_bytes_in_page(page, col + 8, ~dat, 8);
        }
        dat = ~dat;
    }
}

void display_16x16()
{

    unsigned char page;
    unsigned char col;
    unsigned char dat = 0xFF;

    for (page = 0; page < 8; page++)
    {
        if (page % 2 == 0)
        {
            dat = ~dat;
        }
        for (col = 0; col < 128; col += 32)
        {
            lcd_display_same_bytes_in_page(page, col, dat, 16);
            lcd_display_same_bytes_in_page(page, col + 16, ~dat, 16);
        }
    }
}

void display_32x32()
{

    unsigned char page;
    unsigned char col;
    unsigned char dat = 0xFF;

    for (page = 0; page < 8; page++)
    {
        if (page % 4 == 0)
        {
            dat = ~dat;
        }
        for (col = 0; col < 128; col += 64)
        {
            lcd_display_same_bytes_in_page(page, col, dat, 32);
            lcd_display_same_bytes_in_page(page, col + 32, ~dat, 32);
        }
    }
}

void main()
{
    lcd_init();
    lcd_clear_screan();
    display_32x32();
    while (1)
    {
    }
}